<template>
  <div class="todoPageWrapper">
    <a-spin :spinning="spinning" v-if="$route.name === '待办中心'">
      <div class="toDoPage">
        <a-row :gutter="16" >
          <a-col :span="24">
            <div class="tabBox">
              <tab-change ref="tabChange" :select-tab-key="selectTabKey" :dropdown-key="dropdownKey"
                          :to-do-process-num="toDoProcessNum"
                          :out-task="outTask" :to-reviewed-task="toReviewedTask"
                          @tabCallBackT="tabCallBack(selectTabKey,dropdownKey)"></tab-change>
              <div class="ikm" v-if="selectTabKey ==2"><a @click="toIkmPage('如何汇报项目任务？')">如何汇报项目任务？</a></div>
            </div>
            <div class="tableItem">
              <a-row>
                <a-col :span="6">
                  <span class="tabItemTitle" v-if="selectTabKey == '1'">{{$t('todoPage.processList')}}</span> 
                  <span class="tabItemTitle" v-else-if="selectTabKey == '2'">
                    <a-button type="primary" @click="showApplyComplete(1)">{{$t('todoPage.applicationCompleted')}}</a-button>
                  </span>
                  <span class="tabItemTitle" v-else-if="selectTabKey == '3'">{{$t('todoPage.auditTaskList')}}</span>
                  <div>
                    <!--动态显示抽屉（单条/多条）抽屉打开不能再次刷新方法 在父组件添加v-if-->
                    <component :is="applyCom" :drawerVisible_p="drawVisible" v-if="drawVisible" :oid="oid"
                      :assignmentOid="assignmentOid"
                      :taskName="taskName"
                      :dataStatus="dataStatus"
                      :isHaveDelive="isHaveDelive"
                      :action="taskAction"
                      @closeDraw="closeApplyComplete"
                      :dataObj="carryTaskValue"
                      ></component>
                  </div>
                </a-col>
                <a-col :span="18" class="todoSearch">
                  <div class="selectStatus" v-if="selectTabKey == '1'">
                    <div class="targetStatus">{{$t('todoPage.status.processStatus')}} :</div>
                    <a-select style="width: 80%" :default-value="dropdownKey" v-model="dropdownKey"
                              @change="workDropDown">
                      <a-select-option :key="index" :value="item.key" v-for="(item, index) in targetStatusList_process">
                        {{ item.display }}
                      </a-select-option>
                    </a-select>
                  </div>
                  <div class="selectStatus" v-if="selectTabKey == '2'">
                    <div class="targetStatus">{{$t('todoPage.status.taskStatus')}} :</div>
                    <a-select style="width: 100%" :default-value="dropdownKey" v-model="dropdownKey"
                              @change="projectDropDown(selectTabKey,dropdownKey)">
                      <a-select-option :key="index" :value="item.key" v-for="(item, index) in targetStatusList_task">
                        {{ item.display }}
                      </a-select-option>
                    </a-select>
                  </div>
                  <div class="selectStatus" v-if="selectTabKey == '3'">
                    <div class="targetStatus">{{$t('todoPage.status.taskStatus')}} :</div>
                    <a-select style="width: 100%" :default-value="dropdownKey" v-model="dropdownKey"
                              @change="projectDropDown(selectTabKey,dropdownKey)">
                      <a-select-option :key="index" :value="item.key" v-for="(item, index) in targetStatusList_taskNo">
                        {{ item.display }}
                      </a-select-option>
                    </a-select>
                  </div>
                  <div class="inputBox">
                    <global-search ref="global_search" :searchTableData="lastTableData"
                                  @onSearch="onSearchCallBack"></global-search>
                    <!--                <a-input-search placeholder="请输入搜索关键词" style="width: 220px" v-model="searchInput" @search="test"/>-->
                  </div>
                </a-col>
              </a-row>
              <a-row style="margin: 20px 20px 0px 20px;">
                <!-- @routerPageThem="routerPageThem" -->
                <common-table
                  :columns="toDoColumns"
                  :tableData="tableData"
                  :selectType="'checkbox'"
                  :data-row-key="tableKey"
                  :filterData="filterDataTable"
                  @filterTable="filterTable"
                  @routerPage="routerPage"
                  @routerActionPage="routerActionPage"
                  @routerDeliverable="routerDeliverable"
                  @routerToProject="routerToProject"
                  :is-rows-select-visible="isRowsSelectVisible"
                  :loadVisible="false"
                  :this-table-name="thisTableName"
                  :this-table-header-data="thisTableHeaderData"
                  :this-table-header-data-middel="thisTableHeaderDataMiddel"
                  @paginationFun="paginationFun"
                  ref="commonTable"
                ></common-table>
              </a-row>
            </div>
          </a-col>
        </a-row>
      </div>
    </a-spin>
    <router-view :key="$route.name" v-if="$route.name !== '待办中心' && !$route.meta.keepAlive" class=""></router-view>
    <keep-alive>
    <router-view :key="$route.name" v-if="$route.name !== '待办中心' && $route.meta.keepAlive" class=""></router-view>
    </keep-alive>
  </div>
  <!-- <router-view v-else ></router-view> -->
</template>
<script>
import globalSearch from "@/components/common/globalSearch";
import commonTable from "@/components/common/commonTable";
import applyCompleteOnce from "@views/plmHomePage/toDoPage/applyCompleteOnce";
import applyCompleteMore from "@views/plmHomePage/toDoPage/applyCompleteMore";
import {
  getWorkItemAttrs,
  getWorkItemList,
  getProjectTaskAttrs,
  getProjectTaskList,
  getProjectTaskAttrsForApproval,
  getProjectTaskListForApproval
} from "@/api/todoPage";
import carryTask from "@views/plmHomePage/toDoPage/carryTask";
import carryTaskNoDo from "@views/plmHomePage/toDoPage/carryTaskNoDo";
import examineTask from "@views/plmHomePage/toDoPage/examineTask";
import deliverableList from "@views/plmHomePage/toDoPage/deliverableList";
import { getCustomizeHeaders, userinfo } from "@/api/middleGround";
import _ from "lodash";
import { getProjectCaches } from "@/api/projectManage";
import tabChange from "@views/plmHomePage/toDoPage/comp/tabChange";
// import { todopage } from '@/views/plmHomePage/projectPlanningDoc/mixins/todoPage'
import { closeSingleTabs } from '@/api/common'
import { columnsDemand } from '@/components/portalModules/dealtCenter/columnsDemand'
import { getQisUrl } from'@/api/qualityInfoSystem.js'
import { nameUrl } from'@/api/qualityInfoSystem.js'
export default {
  name: "toDoPage",
  // mixins: [todopage],
  data() {
    return {
      spinning: false,
      selectTabKey: "1", //选中的tab的key
      isRowsSelectVisible: false, //表格复选框是否显示
      toDoProcessNum: 0, //待办流程数量
      outTask: 0, //执行任务
      toReviewedTask: 0, //待审核任务
      targetStatusList_process: [
        { key: "ALL", display: "全部" },
        { key: "NOT_COMPLETED", display: "进行中" },
        { key: "COMPLETED", display: "已完成" },
      ], //流程状态下拉框
      targetStatusList_task: [
        { key: "ALL", display: "全部" },
        { key: "WORKING", display: "执行中" },
        { key: "COMPLETED", display: "已完成" },
      ], //执行任务状态下拉框
      targetStatusList_taskNo: [
        { key: "ALL", display: "全部" },
        { key: "PENDINGAPPROVAL", display: "待审核" },
        { key: "COMPLETED", display: "已完成" },
      ], //审核任务状态下拉框
      dropdownKey: "NOT_COMPLETED", //下拉框选中的数据
      toDoColumns: [], //页面显示的表头数据
      tableKey: "", //表格的key
      tableData: [], //页面显示的表格数据
      lastTableData: [], //页面显示的表格数据（最后保存）
      loadVisible: false,
      drawVisible: false, //抽屉
      applyCom: "applyCompleteOnce", //抽屉名称
      searchInput: "", //搜索框内容
      thisTableName: "执行任务", //当前表格名称
      thisTableHeaderData: [], //当前表格所有表头数据
      thisTableHeaderDataMiddel: [], //当前表格存在中台的表头数据
      oid: "", //任务id
      assignmentOid: "", //表格中的某个id
      taskName: "产品定义评审-test", //任务名称
      dataStatus: "已完成", //数据状态
      isHaveDelive: "否", //是否有交付物
      healthStatusImgObj: {
        green: require("@/assets/manageMain/green.svg"),
        yellow: require("@/assets/manageMain/yellow.svg"),
        red: require("@/assets/manageMain/red.svg"),
        gray: require("@/assets/manageMain/gray.svg"),
      }, // 健康状态图片对象
      taskAction: "执行任务", //点击表格动作
      filterData: {}, //筛选条件
      filterDataTable: {}, //筛选条件
      carryTaskValue: {}, //执行任务传参
      columnsDemand, // 需求管理列数据
      //分页参数
      pageCount: 10, // 每页显示条数
      startIndex: 0, // 起始页第一条
    };
  },
  components: {
    globalSearch,
    commonTable,
    applyCompleteOnce,
    applyCompleteMore,
    carryTask,
    carryTaskNoDo,
    examineTask,
    deliverableList,
    tabChange,
  },
  computed: {
    // ...mapState(['loadTable']),
    loadNum() {
      return this.$store.state.loadTable.num;
    }, //vuex数据，表头设置点击“确定”，刷新数据
    commitCount() {
      return this.$store.state.commitApply;
    }, //vuex数据，申请完成点击“确定”，刷新数据
  },
  watch: {
    $route() {
      this.initData();
    },
    //监听抽屉打开/关闭
    drawVisible(val) {},
    commitCount(val) {
      if (this.selectTabKey == "2") {
        this.tabCallBack("2", this.dropdownKey); // tab切换
      } else if (this.selectTabKey == "3") {
        this.tabCallBack("3", this.dropdownKey); // tab切换
      }
      this.getTableToDoNum(); //刷新待办数量
    },
    //监听表头设置
    loadNum(value) {
      if (this.$store.state.loadTable.tableName === "待办流程") {
        this.tabCallBack("1", this.dropdownKey); // tab切换
      } else if (this.$store.state.loadTable.tableName === "执行任务") {
        this.tabCallBack("2", this.dropdownKey); // tab切换
      } else if (this.$store.state.loadTable.tableName === "审核任务") {
        this.tabCallBack("3", this.dropdownKey); // tab切换
      }
    },
    selectTabKey(val) {
      this.filterDataTable = this.filterData[this.selectTabKey] || {}
      this.selectTabKey = val
    },
  },
  destroyed(){
    sessionStorage.removeItem('fdIdTitle')
  },
  mounted() {
    if(sessionStorage.getItem('fdIdTitle')){ //飞书接入
      this.getTableData('1', 'NOT_COMPLETED')
    }else{
      let filterData = JSON.parse(sessionStorage.getItem('filterData') || '{}').toDoPage
      if (filterData) {
        this.filterData = filterData
        this.filterDataTable = this.filterData[this.selectTabKey] || {}
      }
      this.initData();
    }
    
  },
  methods: {
    //跳转到ikm页面
    toIkmPage(name) {
      nameUrl({name}).then(res => {
        // console.log(res.data);
        if( res && res.status == 200 ) {
          if( res.data.success == true || res.data.success == 'true' ) {
            if(res.data.message) {
              window.open(res.data.message)
            } else {
              this.$message.warn("暂无内容查看")
            }
          } else {
            this.$message.error(res.data.message || "请求数据失败")
          }
        } else {
          this.$message.error(res.data.message || "请求数据失败")
        }
      })
    },
    // 分页
    paginationFun(pageValue, info) {
      console.log(pageValue);
      if (this.selectTabKey === "1") {
        this.pageCount = pageValue.pageSize
        this.startIndex = pageValue.pageSize * (pageValue.current - 1 )
        this.getTableData("1", this.dropdownKey);
      }
    },
    // 初始化数据
    initData() {
      // debugger
      this.tabCallBack("1", this.dropdownKey); // tab切换
      this.getTableToDoNum(); //获取表格待操作的数量
    },
    // 流程下拉框搜素
    workDropDown(value) {
      this.dropdownKey = value;
      this.getTableData("1", value);
    },
    // 任务下拉框搜素
    projectDropDown(tabKey, value) {
      this.dropdownKey = value;
      this.getTableData(tabKey, value);
    },
    filterTable(filterData) {
      this.filterData[this.selectTabKey] = filterData;
      let filterDataSession = JSON.parse(
        sessionStorage.getItem("filterData") || "{}"
      );
      filterDataSession.toDoPage = this.filterData;
      sessionStorage.setItem("filterData", JSON.stringify(filterDataSession));
    },
    // tab切换
    tabCallBack(tabKey, status) {
      if (this.$refs.tabChange) {
        this.selectTabKey = this.$refs.tabChange && this.$refs.tabChange.selectTabKeyT;
        tabKey = this.$refs.tabChange && this.$refs.tabChange.selectTabKeyT;
      } else {
        this.selectTabKey = '1'
        tabKey = '1'
      }
      
      //获取表头
      if (tabKey == "1") {
        this.dropdownKey = "NOT_COMPLETED";
        status = this.dropdownKey;
        this.thisTableName = "待办流程"; //当前表格名称
        this.getMiddleHeaderData("1", "待办流程");
        this.getTableData("1", status); //获取表格数据
        this.tableKey = "workItemOid";
        /*this.thisTableHeaderDataSort = ["操作", "进程名称", "流程名称", "状态", "创建时间", "角色", "完成者", "完成日期", "状况", "工作负责人",
          "备注", "最后期限", "流程类型", "项目名称", "创建者"]//当前表格全部表头排序的数据(左侧暂不用排序)*/
      } else if (tabKey == "2") {
        this.dropdownKey = "WORKING";
        status = this.dropdownKey;
        this.thisTableName = "执行任务"; //当前表格名称
        this.getMiddleHeaderData("2", "执行任务");
        this.getTableData("2", status); //获取表格数据
        this.tableKey = "activityOid";
        /*this.thisTableHeaderDataSort = ["操作", "任务名称", "是否有交付物", "交付物", "项目名称", "状态", "任务发布时间", "健康状态", "审核人", "审批意见",
          "执行人", "交付物状态", "目标完成时间", "目标工期", "实际完成时间","所属计划"]//当前表格全部表头排序的数据(左侧暂不用排序)*/
      } else if (tabKey == "3") {
        this.dropdownKey = "PENDINGAPPROVAL";
        status = this.dropdownKey;
        this.thisTableName = "审核任务"; //当前表格名称
        this.getMiddleHeaderData("3", "审核任务");
        this.getTableData("3", status); //获取表格数据
        this.tableKey = "activityOid";
        /*this.thisTableHeaderDataSort = ["操作", "任务名称", "是否有交付物", "交付物", "项目名称", "状态", "任务发布时间", "健康状态", "审核人", "审批意见",
          "执行人", "交付物状态", "目标完成时间", "目标工期", "实际完成时间","所属计划"]//当前表格全部表头排序的数据(左侧暂不用排序)*/
      }
    },
    // 1.获取执行任务表头表头------>分两步：1.先获取中台的自定义设置表头，返回有数据则显示中台数据；2.若中台无返回数据，则获取所有表头
    getMiddleHeaderData(tabKey, tableName) {
      //获取中台接口
      let middleParms = {
        tableName: tableName,
        userId: userinfo.loginName,
      };
      getCustomizeHeaders(middleParms).then((res) => {
        if (res.status === 200 && res.data) {
          let middleHeadersDataOld = res.data.labelList;
          if (
            middleHeadersDataOld.length > 0) {
            this.thisTableHeaderDataMiddel = middleHeadersDataOld.split(",");
            this.getColumns(tabKey, this.thisTableHeaderDataMiddel);
          } else {
            // this.thisTableHeaderDataMiddel = []
            this.getColumns(tabKey, []);
          }
        } else {
          this.$message.error("获取表头失败");
          this.thisTableHeaderDataMiddel = [];
        }
      });
    },
    getColumns(tabKey, headersData) {
      this.toDoColumns = [];
      // key=1为待办流程；key=2为执行任务；key=3为待审核任务
      if (tabKey == "1") {
        getWorkItemAttrs().then((res) => {
          if (res && res.status === 200) {
            if (res.data && res.data.data && res.data.success) {
              if (res.data.data.length > 0) {
                this.thisTableHeaderData = _.clone(res.data.data); //所有表格头数据
                let columnData = res.data.data;
                columnData.forEach((item, index) => {
                  // 项目名称
                  // if(index == 0){
                  //     item.fixed = 'left'
                  // }
                  // if(index == 1){
                  //     item.fixed = 'left'
                  // }
                  // if(index == 2){
                  //     item.fixed = 'left'
                  // }
                  if (
                    item.name === "activity.name" ||
                    item.name === "operation"
                  ) {
                    item.scopedSlots = {
                      customRender: "name",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "process.container") {
                    item.scopedSlots = {
                      customRender: "projectName",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "workItem.theme") {
                    item.scopedSlots = {
                      customRender: "theme",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else {
                    item.scopedSlots = {
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                      customRender: "customRender",
                    };
                  }
                });
                let arrNew = [];
                if (headersData.length > 0) {
                  arrNew = _.filter(columnData, function (o) {
                    return headersData.indexOf(o.displayName) !== -1;
                  });
                  arrNew = _.sortBy(arrNew, (rec) => {
                    return headersData.indexOf(rec.displayName);
                  });
                } else {
                  arrNew = columnData;
                }
                //添加设置表头按钮
                arrNew.push({
                  dataIndex: "setting",
                  fixed: "right",
                  width: 40,
                  slots: { title: "customTitle" },
                });
                //在第一列添加√（当状态为已完成）
                // arrNew.unshift({
                //   dataIndex: "workComplete",
                //   width: 40,
                //   scopedSlots: { customRender: "workComplete" },
                // });
                /*//获取“交付物”下标，并在后方加上小眼睛图标
                let deliverIndex = _.findIndex(arrNew, (rec => {
                  return rec.displayName === '交付物'
                }))
                if (deliverIndex > -1) {
                  arrNew.splice(deliverIndex + 1, 0, {
                    dataIndex: "taskDeliver",
                    width: 20,
                    scopedSlots: {customRender: "taskDeliver"}
                  })
                }*/
                this.toDoColumns = arrNew;
              } else {
                this.toDoColumns = [];
              }
            } else {
              this.toDoColumns = [];
              this.$message.error(res.data.message);
            }
          } else {
            this.$message.error("接口失败");
            this.toDoColumns = [];
          }
        });
      } else if (tabKey == "2") {
        getProjectTaskAttrs().then((res) => {
          if (res && res.status === 200) {
            if (res.data && res.data.data && res.data.success) {
              if (res.data.data.length > 0) {
                this.thisTableHeaderData = _.clone(res.data.data); //所有表格头数据
                let columnData = res.data.data;
                columnData.forEach((item, index) => {
                  // 项目名称（未改动时）
                  // if (item.name === "activity.name" || item.name === "deliverable.status") {
                  //   // item.customCell = this.customCellColor
                  //   item.scopedSlots = {
                  //     customRender: "name",
                  //     filterDropdown: "filterDropdown",
                  //     filterIcon: "filterIcon",
                  //   };
                  // }
                  if (item.name === "activity.name") {
                    // item.fixed = 'left'
                    item.scopedSlots = {
                      customRender: "name",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "activity.operation") {
                    item.scopedSlots = {
                      customRender: "action",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "deliverable.name") {
                    item.scopedSlots = {
                      customRender: "taskDeliverable",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "project.name") {
                    item.scopedSlots = {
                      customRender: "projectName",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "assignment.healthStatusType") {
                    item.scopedSlots = {
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                      customRender: "img",
                    };
                  } else {
                    item.scopedSlots = {
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                      customRender: "customRender",
                    };
                  }
                });
                let arrNew = [];
                if (headersData.length > 0) {
                  arrNew = _.filter(columnData, function (o) {
                    return headersData.indexOf(o.displayName) !== -1;
                  });
                  arrNew = _.sortBy(arrNew, (rec) => {
                    return headersData.indexOf(rec.displayName);
                  });
                } else {
                  arrNew = columnData;
                }
                //添加设置表头按钮
                arrNew.push({
                  dataIndex: "setting",
                  fixed: "right",
                  width: 40,
                  slots: { title: "customTitle" },
                });
                //在第一列添加√（当状态为已完成）
                // arrNew.unshift({
                //   dataIndex: "taskComplete",
                //   width: 30,
                //   scopedSlots: { customRender: "taskComplete" },
                // });
                this.toDoColumns = arrNew;
              } else {
                this.toDoColumns = [];
              }
            } else {
              this.toDoColumns = [];
              this.$message.error(res.data.message);
            }
          } else {
            this.$message.error("接口失败");
            this.toDoColumns = [];
          }
        });
      } else if (tabKey == "3") {
        getProjectTaskAttrsForApproval().then((res) => {
          if (res && res.status === 200) {
            if (res.data && res.data.data && res.data.success) {
              if (res.data.data.length > 0) {
                this.thisTableHeaderData = _.clone(res.data.data); //所有表格头数据
                let columnData = res.data.data;
                columnData.forEach((item, index) => {
                  // 项目名称
                  if (
                    item.name === "activity.name" ||
                    item.name === "deliverable.status"
                  ) {
                    item.scopedSlots = {
                      customRender: "name",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "activity.operation") {
                    item.scopedSlots = {
                      customRender: "action",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "deliverable.name") {
                    item.scopedSlots = {
                      customRender: "taskDeliverable",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "project.name") {
                    item.scopedSlots = {
                      customRender: "projectName",
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                    };
                  } else if (item.name === "assignment.healthStatusType") {
                    item.scopedSlots = {
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                      customRender: "img",
                    };
                  } else {
                    item.scopedSlots = {
                      filterDropdown: "filterDropdown",
                      filterIcon: "filterIcon",
                      customRender: "customRender",
                    };
                  }
                });
                let arrNew = [];
                if (headersData.length > 0) {
                  arrNew = _.filter(columnData, function (o) {
                    return headersData.indexOf(o.displayName) !== -1;
                  });
                  arrNew = _.sortBy(arrNew, (rec) => {
                    return headersData.indexOf(rec.displayName);
                  });
                } else {
                  arrNew = columnData;
                }
                //添加设置表头按钮
                arrNew.push({
                  dataIndex: "setting",
                  fixed: "right",
                  width: 40,
                  slots: { title: "customTitle" },
                });
                //在第一列添加√（当状态为已完成）
                arrNew.unshift({
                  dataIndex: "taskComplete",
                  width: 30,
                  scopedSlots: { customRender: "taskComplete" },
                });
                /*//获取“交付物”下标，并在后方加上小眼睛图标
                let deliverIndex = _.findIndex(arrNew, (rec => {
                  return rec.displayName === '交付物'
                }))
                if (deliverIndex > -1) {
                  arrNew.splice(deliverIndex + 1, 0, {
                    dataIndex: "taskDeliver",
                    width: 20,
                    scopedSlots: {customRender: "taskDeliver"}
                  })
                }*/
                this.toDoColumns = arrNew;
              } else {
                this.toDoColumns = [];
              }
            } else {
              this.toDoColumns = [];
              this.$message.error(res.data.message);
            }
          } else {
            this.$message.error("接口失败");
            this.toDoColumns = [];
          }
        });
      } else if (tabKey == "4") {
        console.log(tabKey)
      }
    },
    // 获取表格数据
    getTableData(tabKey, status) {
      this.$refs.commonTable.pagination.total = 0
      this.loadVisible = false;
      this.tableData = [];
      // key=1为待办流程；key=2为执行任务；key=3为待审核任务
      if (tabKey == "1") {
        this.isRowsSelectVisible = false;
        let parms = {
          // "userId": "wcadmin",
          status: status,
          "pagingSearch": true,
          "count": this.pageCount,
          "startIndex": this.startIndex
        };
        //OR:wt.workflow.work.WfAssignedActivity:1862217
        this.spinning = true;
        getWorkItemList(parms).then((res) => {
          if (res && res.status === 200) {
            if (res.data && res.data.data && res.data.success) {
              if (res.data.data.length > 0) {
                this.tableData = _.orderBy(res.data.data, ['workItem.thePersistInfo.createStamp'], ['desc'])//按照创建时间降序排序
                this.lastTableData = _.clone(_.orderBy(res.data.data, ['workItem.thePersistInfo.createStamp'], ['desc']))
                this.loadVisible = false
                if(sessionStorage.getItem('fdIdTitle')){
                  this.tableData = res.data.data.filter(item=>{
                    return item.pboOid == sessionStorage.getItem('fdIdTitle');
                  })
                  this.routerPage(this.tableData[0])
                }
                setTimeout(() => {
                  if (this.$refs.global_search) {
                    this.$refs.global_search.searchValue = '';
                    this.$refs.global_search.onSearch()
                  }
                }, 20)
                this.spinning = false
              } else {
                this.tableData = [];
                this.loadVisible = false;
                this.spinning = false
              }
              this.$refs.commonTable.pagination.total = res.data.size
            } else {
              this.tableData = [];
              this.loadVisible = false;
              this.$message.error(res.data.message);
              this.spinning = false
              this.$refs.commonTable.pagination.total = 0
            }
          } else {
            this.tableData = [];
            this.loadVisible = false;
            this.$message.error("接口失败");
            this.spinning = false
            this.$refs.commonTable.pagination.total = 0
          }
          this.spinning = false;
        }).catch(()=>{
          this.spinning = false;
        });
      } else if (tabKey == "2") {
        this.isRowsSelectVisible = true;
        let parms = {
          // "userId": "wcadmin",
          status: status,
        };
        this.spinning = true;
        getProjectTaskList(parms).then((res) => {
          if (res && res.status === 200) {
            if (res.data && res.data.data && res.data.success) {
              if (res.data.data.length > 0) {
                res.data.data.map((item) => {
                  if (item["assignment.healthStatusType"] === "灰") {
                    item.healthstatusimg = this.healthStatusImgObj.gray;
                  } else if (item["assignment.healthStatusType"] === "绿") {
                    item.healthstatusimg = this.healthStatusImgObj.green;
                  } else if (item["assignment.healthStatusType"] === "黄") {
                    item.healthstatusimg = this.healthStatusImgObj.yellow;
                  } else if (item["assignment.healthStatusType"] === "红") {
                    item.healthstatusimg = this.healthStatusImgObj.red;
                  }
                });
                // this.tableData = res.data.data
                this.tableData = _.orderBy(
                  res.data.data,
                  ["assignment.openTaskDate"],
                  ["desc"]
                ); //按照创建时间降序排序
                this.lastTableData = _.clone(
                  _.orderBy(
                    res.data.data,
                    ["assignment.openTaskDate"],
                    ["desc"]
                  )
                );
                this.loadVisible = false;
                setTimeout(() => {
                  this.$refs.global_search.searchValue = "";
                  this.$refs.global_search.onSearch();
                }, 20);
                this.spinning = false
              } else {
                this.tableData = [];
                this.loadVisible = false;
                this.spinning = false
              }
            } else {
              this.tableData = [];
              this.loadVisible = false;
              this.$message.error(res.data.message);
              this.spinning = false
            }
          } else {
            this.tableData = [];
            this.loadVisible = false;
            this.$message.error("接口失败");
          }
          this.spinning = false;
        }).catch(()=>{
          this.spinning = false;
        });
      } else if (tabKey == "3") {
        this.isRowsSelectVisible = false;
        let parms = {
          // "userId": "wcadmin",
          status: status,
        };
        this.spinning = true;
        getProjectTaskListForApproval(parms).then((res) => {
          if (res && res.status === 200) {
            if (res.data && res.data.data && res.data.success) {
              if (res.data.data.length > 0) {
                res.data.data.map((item) => {
                  if (item["assignment.healthStatusType"] === "灰") {
                    item.healthstatusimg = this.healthStatusImgObj.gray;
                  } else if (item["assignment.healthStatusType"] === "绿") {
                    item.healthstatusimg = this.healthStatusImgObj.green;
                  } else if (item["assignment.healthStatusType"] === "黄") {
                    item.healthstatusimg = this.healthStatusImgObj.yellow;
                  } else if (item["assignment.healthStatusType"] === "红") {
                    item.healthstatusimg = this.healthStatusImgObj.red;
                  }
                });
                this.tableData = _.orderBy(
                  res.data.data,
                  ["assignment.openTaskDate"],
                  ["desc"]
                ); //按照创建时间降序排序
                this.lastTableData = _.clone(
                  _.orderBy(
                    res.data.data,
                    ["assignment.openTaskDate"],
                    ["desc"]
                  )
                );
                this.loadVisible = false;
                setTimeout(() => {
                  this.$refs.global_search.searchValue = "";
                  this.$refs.global_search.onSearch();
                }, 20);
                this.spinning = false
              } else {
                this.tableData = [];
                this.loadVisible = false;
                this.spinning = false
              }
            } else {
              this.tableData = [];
              this.loadVisible = false;
              this.$message.error(res.data.message);
              this.spinning = false
            }
          } else {
            this.tableData = [];
            this.loadVisible = false;
            this.$message.error("接口失败");
            this.spinning = false
          }
          this.spinning = false;
        }).catch(()=>{
          this.spinning = false;
        });
      }
      
    },
    //获取表格待办的数量
    getTableToDoNum() {
      //待办流程数量
      let parms_1 = {
        status: "NOT_COMPLETED",
        "pagingSearch": true,
        "count": this.pageCount,
        "startIndex": this.startIndex
      };
      getWorkItemList(parms_1).then((res) => {
        if (res && res.status === 200) {
          if (res.data && res.data.data && res.data.success) {
            if (res.data.data.length > 0) {
              // this.toDoProcessNum = res.data.data.length;
              this.toDoProcessNum = res.data.size
            } else {
              this.toDoProcessNum = 0;
            }
          } else {
            this.toDoProcessNum = 0;
            this.$message.error(res.data.message);
          }
        } else {
          this.toDoProcessNum = 0;
          this.$message.error("接口失败");
        }
        this.$store.commit("setTodoProcessNum", this.toDoProcessNum);
      });
      //待执行任务数量
      let parms_2 = {
        // "userId": "wcadmin",
        status: "WORKING",
      };
      getProjectTaskList(parms_2).then((res) => {
        if (res && res.status === 200) {
          if (res.data && res.data.data && res.data.success) {
            if (res.data.data.length > 0) {
              this.outTask = res.data.data.length;
            } else {
              this.outTask = 0;
            }
          } else {
            this.outTask = 0;
            this.$message.error(res.data.message);
          }
        } else {
          this.outTask = 0;
          this.$message.error("接口失败");
        }
        this.$store.commit("setOutTask", this.outTask);
      });
      //待审核任务数量
      let parms_3 = {
        // "userId": "wcadmin",
        status: "PENDINGAPPROVAL",
      };
      getProjectTaskListForApproval(parms_3).then((res) => {
        if (res && res.status === 200) {
          if (res.data && res.data.data && res.data.success) {
            if (res.data.data.length > 0) {
              this.toReviewedTask = res.data.data.length;
            } else {
              this.toReviewedTask = 0;
            }
          } else {
            this.toReviewedTask = 0;
          }
        } else {
          this.$message.error("接口失败");
        }
        this.$store.commit("setToReviewedTask", this.toReviewedTask);
      });
    },
    goRouterQis(oid) {
      getQisUrl({oid}).then(res => {
        if(res.data.message) {
          window.open(unescape(res.data.message))
        } else {
          this.$message.warning('地址不存在')
        }
      })
    },
    // 第一个tab，点击“操作”跳转 || 点击第二个tab中任务名称显示的抽屉
    routerPage(val) {
      const projectObj = {
        projectName: val['process.container'],
        projectType:  val['process.project.type']
      }
      sessionStorage.setItem("ProjectObj", JSON.stringify(projectObj))
      sessionStorage.setItem("fromRouteName", "todoPageList")
      /* session值项目名称--头部  开始  */
      if (val.pboOid && val.pboOid.indexOf("Planning") == -1) {
        let str = "";
        if (this.selectTabKey === "1") {
          str = val["process.container.oid"];
        } else {
          str = val.projectOid;
        }
        if(str){    //仿真委托书不属于项目里面的，所有委托书的流程里没有项目的oid
          sessionStorage.setItem("oid", str && str.substring(str.lastIndexOf(":") + 1));
        }
      }
      /* session值项目名称--头部  结束   */
      if (this.selectTabKey == "1") {
        // /** 出现报错信息 */
        // if (val['errMsg']) {
        //   this.$confirm({
        //     cancelText: "否",
        //     okText: "是",
        //     content: val['errMsg'],
        //     onOk: () => {
        //       this.jumpFun(val)
        //     },
        //     onCancel() {}
        //   })
        // } else {
        // this.jumpFun(val)
        // }
        if (
          val["pbo.localizedType"].indexOf("文档") > -1 ||
          // val["pbo.localizedType"].indexOf("PM") > -1 ||
          val["pboOid"].indexOf("WTDocument") != -1
        ) {
          //待办流程点击操作跳转至流程交付物页面（操作界面）
          let fileSingleTableItem_s = {
            oid: val['workItemOid'],//流程oid
            singleOid:val['pboOid'],  //文档Oid
            workItemName: val['operation'],//流程节点名称
            state: val['pbo.state'],//流程状态
            // pboOid: val['pboOid'],//交付物id
            workItemState: val['workItem.status']//交付物状况
          }
          sessionStorage.setItem("fileSingleTableItem", JSON.stringify(fileSingleTableItem_s))
          this.$store.commit('SET_PROJECT_FILE_TITLE', '')
          closeSingleTabs()
          this.$router.push({
            path: "/single/fileSingle/examineProject",
          });
        } else if (val["pboOid"].indexOf("ProjectKnotItemBook") != -1) {
          /**验收表流程入口 */
          let fileSingleTableItem_s = {
            oid: val['workItemOid'],//流程oid
            workItemName: val['operation'],//流程节点名称
            state: val['pbo.state'],//流程状态
            pboOid: val['pboOid'],//验收表id
            workItemState: val['workItem.status'],//验收表状况
            processName: val['workItem.theme']
          }
          sessionStorage.setItem("acceptListData", JSON.stringify(fileSingleTableItem_s))
          let typeObj = {
            type: 'process',
            acceptId: val['pboOid']
          }
          sessionStorage.setItem('processAcceptInfo', JSON.stringify(typeObj))
          // sessionStorage.setItem('acceptProcessInfo', JSON.stringify(fileSingleTableItem_s))
          closeSingleTabs()
          this.$router.push({
            path: '/single/projectAcceptList/porjectAcceptProcess',
            query: {
              isJump: true
            },
          })
        } else if (val['process.name'].startsWith("QIS")) {
          closeSingleTabs()
          this.goRouterQis(val.workItemOid)
        } else if (val.pboOid.indexOf("sany.pmgt.tdm.model") != -1) {
          this.toBookRouterTDM(val)
        } else if (val["pboOid"].indexOf("ProjectIssue") != -1) {
          sessionStorage.setItem('questionItem', JSON.stringify(val))
          closeSingleTabs()
          if(val.operation === "修改"){
            this.$router.push({
              path: '/single/questionSingle/editQuestion',
            })
          }else{
            this.$router.push({
              path: '/single/questionSingle/examineQuestion',
            })
          }
        } else if (val["pboOid"].indexOf("ProjectRisk") != -1) {
          sessionStorage.setItem('riskItem', JSON.stringify(val))
          closeSingleTabs()
          if(val.operation === "修改"){
              this.$router.push({
                path: '/single/riskSingle/examineRiskBack',
              })
          }else{
              this.$router.push({
                path: '/single/riskSingle/examineRisk',
              })
          }
        } else if (val["pboOid"].indexOf("RMTask") != -1) { //需求关联（需求任务单流程）
          sessionStorage.setItem('demandItem', JSON.stringify(val))
          closeSingleTabs()
          if(val.operation === "需求关联" || val.operation === "移除需求关联的项目" || val.operation === "更改需求任务单"){
              this.$router.push({
                // path: '/single/demandSingle/examineDemand',
                path: '/toDoPage/examineDemand',
              })
          }
        } else if (val["pboOid"].indexOf("PPMSubPlan") != -1) { //需求关联（子规划流程）   //&& val['pbo.localizedType'].indexOf('子规划')
          sessionStorage.setItem('ppmdemandItem', JSON.stringify(val))
          closeSingleTabs()
          if(val.operation === "需求关联" || val.operation === "移除需求关联的项目"){
              this.$router.push({
                // path: '/single/demandSingle/childPlan',
                path: '/toDoPage/childPlan',
              })
          }
        } else if (val.pboOid.indexOf("Planning") != -1) {
          closeSingleTabs()
          this.toBookRouter(val)
        } else if (val.pboOid.indexOf("EntrustBook") != -1) {
          if (val['toPlm'] === "true") {
            this.$message.warn('非项目仿真委托需去PLM系统处理')
            return false
          }
          console.log('仿真委托书流程信息',val);
          this.toBookRouterSDM(val);      //SDM仿真委托书
        } else if (val["pbo.localizedType"].indexOf('评审') > -1 || val["pboOid"].indexOf("PIReview") != -1){
          sessionStorage.setItem('reviewId',val.pboOid)
          sessionStorage.setItem("workItemOid",val.workItemOid)
          sessionStorage.setItem("techProcessName",val['process.name'])
          sessionStorage.setItem("craftOperation",val.operation) 
          closeSingleTabs()
          if(val.operation === "审阅"){
            this.$router.push({
              path: "/single/reviewSingle/selfCheck",
            });
          } else if (val.operation === "修改完善") {
            this.$router.push({
              path: "/single/reviewSingle/modifyPerfect",
            });
          } else if (val.operation === "修改") {
            this.$router.push({
              path: "/single/reviewSingle/rejectModify",
            });
          } else {
            sessionStorage.setItem("operation", val.operation)
            this.$router.push({
              path: '/single/reviewSingle/PMOReview',    
              // query: {
              //   operation: val.operation
              // }     
            })
          }
        } else if (val['process.name'].indexOf('SNProjectCloseWF') != -1) {
          //项目关闭 SNProjectCloseWF    process.name
          sessionStorage.setItem("closedData", JSON.stringify(val));
          closeSingleTabs()
          this.$router.push({
            path: "/single/fileSingle/closeExamine",
          });
        } else if (val["pbo.localizedType"].indexOf("项目变更") > -1 || val["pboOid"].indexOf("PIProjectChangeRequest") != -1 ) { //项目变更
          sessionStorage.setItem("changeAlterationData", JSON.stringify(val));
          closeSingleTabs()
          if(val.operation === "修改"){
            let str = val['process.container.oid'];
            sessionStorage.setItem("oid", str.substring(str.lastIndexOf(":") + 1));
            this.$router.push({
              path: "/single/projectAlteration/editAlteration",
            });
          }else{
            this.$router.push({
              path: "/single/projectAlteration/changeAlteration",
            });
          }
        } else {
          // this.$message.info("暂不支持该流程操作！");
          window.open(val['process.name.url'])
        }
        
      } else if (this.selectTabKey == "2") {
        // this.tableKey = "activityOid"
        this.oid = val.activityOid;
        this.assignmentOid = val.assignmentOid;
        this.taskName = val["activity.name"];
        this.dataStatus = val["assignment.plannableStatus"];
        this.isHaveDelive = val["hasPIDeliverable"];
        this.taskAction = "";
        // this.$store.commit('commitApplyAdd')//刷新抽屉中的数据
        this.showApplyComplete(5); //执行任务 (zj)
      } else if (this.selectTabKey == "3") {
        // this.tableKey = "activityOid"
        this.oid = val.activityOid;
        this.assignmentOid = val.assignmentOid;
        this.taskName = val["activity.name"];
        this.dataStatus = val["assignment.plannableStatus"];
        this.isHaveDelive = val["hasPIDeliverable"];
        this.taskAction = "";
        // this.$store.commit('commitApplyAdd')//刷新抽屉中的数据
        this.showApplyComplete(4); //审核任务
      }
    },
    jumpFun(val) {
      if (
          val["pbo.localizedType"].indexOf("文档") > -1 ||
          val["pbo.localizedType"].indexOf("PM") > -1 ||
          val["pboOid"].indexOf("WTDocument") != -1
        ) {
          //待办流程点击操作跳转至流程交付物页面（操作界面）
          let fileSingleTableItem_s = {
            oid: val['workItemOid'],//流程oid
            singleOid:val['pboOid'],  //文档Oid
            workItemName: val['operation'],//流程节点名称
            state: val['pbo.state'],//流程状态
            // pboOid: val['pboOid'],//交付物id
            workItemState: val['workItem.status']//交付物状况
          }
          sessionStorage.setItem("fileSingleTableItem", JSON.stringify(fileSingleTableItem_s))
          this.$store.commit('SET_PROJECT_FILE_TITLE', '')
          closeSingleTabs()
          this.$router.push({
            path: "/single/fileSingle/examineProject",
          });
        } else if (val["pboOid"].indexOf("ProjectKnotItemBook") != -1) {
          /**验收表流程入口 */
          let fileSingleTableItem_s = {
            oid: val['workItemOid'],//流程oid
            workItemName: val['operation'],//流程节点名称
            state: val['pbo.state'],//流程状态
            pboOid: val['pboOid'],//验收表id
            workItemState: val['workItem.status'],//验收表状况
            processName: val['workItem.theme']
          }
          sessionStorage.setItem("acceptListData", JSON.stringify(fileSingleTableItem_s))
          let typeObj = {
            type: 'process',
            acceptId: val['pboOid']
          }
          sessionStorage.setItem('processAcceptInfo', JSON.stringify(typeObj))
          // sessionStorage.setItem('acceptProcessInfo', JSON.stringify(fileSingleTableItem_s))
          closeSingleTabs()
          this.$router.push({
            path: '/single/projectAcceptList/porjectAcceptProcess',
            query: {
              isJump: true
            },
          })
        } else if (val['process.name'].startsWith("QIS")) {
          closeSingleTabs()
          this.goRouterQis(val.workItemOid)
        } else if (val.pboOid.indexOf("sany.pmgt.tdm.model") != -1) {
          this.toBookRouterTDM(val)
        } else if (val["pboOid"].indexOf("ProjectIssue") != -1) {
          sessionStorage.setItem('questionItem', JSON.stringify(val))
          closeSingleTabs()
          if(val.operation === "修改"){
            this.$router.push({
              path: '/single/questionSingle/editQuestion',
            })
          }else{
            this.$router.push({
              path: '/single/questionSingle/examineQuestion',
            })
          }
        } else if (val["pboOid"].indexOf("ProjectRisk") != -1) {
          sessionStorage.setItem('riskItem', JSON.stringify(val))
          closeSingleTabs()
          if(val.operation === "修改"){
              this.$router.push({
                path: '/single/riskSingle/examineRiskBack',
              })
          }else{
              this.$router.push({
                path: '/single/riskSingle/examineRisk',
              })
          }
        } else if (val.pboOid.indexOf("Planning") != -1) {
          closeSingleTabs()
          this.toBookRouter(val)
        } else if (val.pboOid.indexOf("EntrustBook") != -1) {
          if (val['toPlm'] === "true") {
            this.$message.warn('非项目仿真委托需去PLM系统处理')
            return false
          }
          console.log('仿真委托书流程信息',val);
          this.toBookRouterSDM(val);      //SDM仿真委托书
        } else if (val["pbo.localizedType"].indexOf('评审') > -1 || val["pboOid"].indexOf("PIReview") != -1){
          sessionStorage.setItem('reviewId',val.pboOid)
          sessionStorage.setItem("workItemOid",val.workItemOid)
          closeSingleTabs()
          if(val.operation === "审阅"){
            this.$router.push({
              path: "/single/reviewSingle/selfCheck",
            });
          } else if (val.operation === "修改完善") {
            this.$router.push({
              path: "/single/reviewSingle/modifyPerfect",
            });
          } else if (val.operation === "修改") {
            this.$router.push({
              path: "/single/reviewSingle/rejectModify",
            });
          } else {
            sessionStorage.setItem("operation", val.operation)
            this.$router.push({
              path: '/single/reviewSingle/PMOReview',    
              // query: {
              //   operation: val.operation
              // }     
            })
          }
        } else if (val['process.name'].indexOf('SNProjectCloseWF') != -1) {
          //项目关闭 SNProjectCloseWF    process.name
          sessionStorage.setItem("closedData", JSON.stringify(val));
          closeSingleTabs()
          this.$router.push({
            path: "/single/fileSingle/closeExamine",
          });
        } else if (val["pbo.localizedType"].indexOf("项目变更") > -1 || val["pboOid"].indexOf("PIProjectChangeRequest") != -1 ) { //项目变更
          sessionStorage.setItem("changeAlterationData", JSON.stringify(val));
          closeSingleTabs()
          if(val.operation === "修改"){
            let str = val['process.container.oid'];
            sessionStorage.setItem("oid", str.substring(str.lastIndexOf(":") + 1));
            this.$router.push({
              path: "/single/projectAlteration/editAlteration",
            });
          }else{
            this.$router.push({
              path: "/single/projectAlteration/changeAlteration",
            });
          }
        } else {
          this.$message.info("暂不支持该流程操作！");
        }
    },
    // 点击第二个和第三个tab切换“操作”跳转
    routerActionPage(val) {
      sessionStorage.setItem("fromRouteName", "todoPageList")
      /* session值项目名称--头部  开始  */
      if (val.pboOid && val.pboOid.indexOf("Planning") == -1) {
        let str = "";
        if (this.selectTabKey === "1") {
          str = val["process.container.oid"];
        } else {
          str = val.projectOid;
        }
        sessionStorage.setItem("oid", str && str.substring(str.lastIndexOf(":") + 1));
      }
      /* session值项目名称--头部  结束   */
      if (this.selectTabKey == "1") {
        if (
          val["pbo.localizedType"].indexOf("文档") > -1 ||
          val["pbo.localizedType"].indexOf("PM") > -1 ||
          val["pboOid"].indexOf("WTDocument") != -1
        ) {
          //待办流程点击操作跳转至流程交付物页面（操作界面）
          let fileSingleTableItem_s = {
            oid: val["workItemOid"], //流程oid
            workItemName: val["operation"], //流程节点名称
            state: val["pbo.state"], //流程状态
            // pboOid: val['pboOid'],//交付物id
            workItemState: val['workItem.status']//交付物状况
          }
          sessionStorage.setItem("fileSingleTableItem", JSON.stringify(fileSingleTableItem_s))
          this.$store.commit('SET_PROJECT_FILE_TITLE', '')
          closeSingleTabs()
          this.$router.push({
            path: "/single/fileSingle/examineProject",
          });
        } else {
          this.$message.info("暂不支持该流程操作！");
        }
      } else if (this.selectTabKey == "2") {
        this.carryTaskValue = val
        sessionStorage.setItem('projectOid',JSON.stringify(val.projectOid))
        // this.tableKey = "activityOid"
        this.oid = val.activityOid;
        this.assignmentOid = val.assignmentOid;
        this.taskName = val["activity.name"];
        this.dataStatus = val["assignment.plannableStatus"];
        this.isHaveDelive = val["hasPIDeliverable"];
        this.taskAction = "执行任务";
        // this.$store.commit('commitApplyAdd')//刷新抽屉中的数据
        let str = val.projectOid
        sessionStorage.setItem('oid', str.substring(str.lastIndexOf(":") + 1));
        this.showApplyComplete(3); //执行任务
      } else if (this.selectTabKey == "3") {
        // this.tableKey = "activityOid"
        this.oid = val.activityOid;
        this.assignmentOid = val.assignmentOid;
        this.taskName = val["activity.name"];
        this.dataStatus = val["assignment.plannableStatus"];
        this.isHaveDelive = val["hasPIDeliverable"];
        this.taskAction = "审核任务";
        // this.$store.commit('commitApplyAdd')//刷新抽屉中的数据
        this.showApplyComplete(4); //审核任务
      }
    },
    //点击交付物跳转
    routerDeliverable(val) {
      sessionStorage.setItem("fromRouteName", "todoPageList")
      if (val.pboOid && val.pboOid.indexOf("Planning") == -1) {
        let str = "";
        if (this.selectTabKey === "1") {
          str = val["process.container.oid"];
        } else {
          str = val.projectOid;
        }
        sessionStorage.setItem("oid", str && str.substring(str.lastIndexOf(":") + 1));
      }
      /* session值项目名称--头部  结束   */
      this.oid = val.activityOid;
      this.showApplyComplete(2); //交付物列表
    },
    //点击流程名称跳转--文件详情
    // routerPageThem(val) {
    //   console.log(val, '1139');
    //   sessionStorage.setItem("fromRouteName", "todoPageList")
    //   /* session值项目名称--头部  开始  */
    //   if (val.pboOid && val.pboOid.indexOf("Planning") == -1) {
    //     let str = "";
    //     if (this.selectTabKey === "1") {
    //       str = val["process.container.oid"];
    //     } else {
    //       str = val.projectOid;
    //     }
    //     sessionStorage.setItem("oid", str.substring(str.lastIndexOf(":") + 1));
    //   }
    //   /* session值项目名称--头部  结束   */
    //   if (
    //     val["pbo.localizedType"].indexOf("文档") > -1 ||
    //     val["pbo.localizedType"].indexOf("PM") > -1
    //   ) {
    //     //待办流程点击操作跳转至流程交付物页面
    //     let fileSingleTableItem_s = {
    //       oid: val["pboOid"], //流程oid
    //       workItemName: val["operation"], //流程节点名称
    //       state: val["pbo.state"], //流程状态
    //       // pboOid: val['pboOid'],//交付物id
    //       workItemState: val['workItem.status'],//交付物状况
    //     }
    //     sessionStorage.setItem("fileSingleTableItem", JSON.stringify(fileSingleTableItem_s))
    //     this.$store.commit('SET_PROJECT_FILE_TITLE', '')
    //     closeSingleTabs()
    //     this.$router.push({
    //       path: "/single/fileSingle/examineProject",
    //     });
    //   } else {
    //     this.$message.info("当前流程不是文档类型，暂不支持详情查看！");
    //   }
    // },
    //每个tab点击项目跳转--单项目首页
    routerToProject(val) {
      console.log(val, 1211);
      sessionStorage.setItem("fromRouteName", "todoPageList")
      /* session值项目名称--头部  开始  */
     if(val.pboOid){
      if(val.pboOid.indexOf("PPMSubPlan") > -1 || val.pboOid.indexOf("RMTask") > -1){
            this.$message.error("该流程没有关联的项目")
      }
     }
      var str = ''
      if (val.pboOid && val.pboOid.indexOf("Planning") == -1) {
        if (this.selectTabKey === "1") {
          str = val["process.container.oid"];
        } else {
          str = val.projectOid;
        }
        sessionStorage.setItem("oid", str && str.substring(str.lastIndexOf(":") + 1));
      } else {
        // let str = ''
        str = val.projectOid;
        sessionStorage.setItem("oid", str && str.substring(str.lastIndexOf(":") + 1));
        // sessionStorage.setItem("oid", str.substring(str.lastIndexOf(":") + 1));
      }
      /* session值项目名称--头部  结束   */
      //获取项目信息
      let arr = []
      arr.push(sessionStorage.getItem("oid"))
      getProjectCaches(arr).then(res => {
        if (res.status === 200) {
          if (res.data && res.data.length > 0) {
            const projectObj = {
              projectName: res.data[0].projectName,
              projectType:  res.data[0].projectType
            }
             sessionStorage.setItem("ProjectObj", JSON.stringify(projectObj))
            if (res.data[0].projectType === '软件开发项目') {
              sessionStorage.setItem("projectSmallType", res.data[0].projectSmallType)
            }
            closeSingleTabs()
            this.$router.push({
              path: '/single/projectMain',
              query: {
                oid: str.substring(str.lastIndexOf(":") + 1)
              }
            })
          }
        } else {
          this.$message.error('获取数据失败')
        }
      })
      // .catch(error => {
      //   this.$message.error('获取数据接口异常')
      // })
    },
    //展开抽屉
    showApplyComplete(num) {
      switch (num) {
        case 1:
          if (this.$store.state.selectedTableData.length === 1) { // 当tab2中只选中一个任务，点击申请完成
            this.applyCom = "applyCompleteOnce";
            this.assignmentOid =
              this.$store.state.selectedTableData[0].assignmentOid;
          } else if (this.$store.state.selectedTableData.length > 1) { // 多个任务，点击申请完成
            this.applyCom = "applyCompleteMore";
          } else {
            this.$message.error("请最少选择一项任务！");
            this.applyCom = "";
          }
          break;
        case 2:
          this.applyCom = "deliverableList";
          break;
        case 3:
          this.applyCom = "carryTask";
          break;
        case 4:
          this.applyCom = "examineTask";
          break;
        case 5:
          this.applyCom = "carryTaskNoDo";
          break;
      }
      this.drawVisible = true;
      // this.$store.commit('commitApplyAdd')//刷新抽屉中的数据
    },
    //关闭抽屉
    closeApplyComplete() {
      this.drawVisible = false;
    },
    // 全局搜索
    onSearchCallBack(tableVal, searchValue) {
      if (!searchValue) {
        // 当传过来的数据为空，并且输入条件为空时，重新调用
        // this.getTableDataParams(t his.defaultTagId)
        this.tableData = _.clone(this.lastTableData);
      } else {
        this.tableData = tableVal;
      }
    },
  },
};
</script>
<style scoped lang="less">
.todoPageWrapper {
  height: 100%;
}
.toDoPage {
  height: 100%;
  min-height: 740px;
  background-color: #fff;
  text-align: center;
  // padding: 200px 0 0 0;
  border-radius: 4px;
  //margin-top: -24px;
  h1 {
    font-size: 48px;
  }
  .tabBox {
    padding: 12px 12px 0px 12px;
    position: relative;
    .ikm {
      position: absolute;
      right: 14px;
      top: 22px;
    }
    // justify-content: space-around;
  }
  .tableItem {
    margin-top: 0px;
    /deep/ .ant-table-body {
      min-height: calc(100vh - 383px);
    }
    /deep/ .ant-table-placeholder {
      min-height: calc(100vh - 383px);
      margin-top: -420px;
      border: none;
    }
    .tabItemTitle {
      float: left;
      padding-left: 20px;
      font-weight: 600;
      color: black;
      font-size: 18px;
    }
    .selectStatus {
      width: 320px;
      display: flex;
      justify-content: flex-start;
      margin-right: 20px;
      .targetStatus {
        color: #666;
        font-size: 14px;
        width: 130px;
        line-height: 32px;
      }
      .targetConclusion {
        width: 120px;
      }
      /deep/ .ant-select-dropdown-menu-item-selected {
        color: #2f54eb;
      }
    }
    .todoSearch {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      padding-right: 20px;
    }
  }
}
</style>
<style scoped>
</style>